home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 163_02 / strncpy.c < prev    next >
Text File  |  1988-01-30  |  512b  |  12 lines

  1. /*
  2. ** copy s2 to s1, truncating or null padding as necessary to create a string
  3. ** n characters long
  4. */
  5. strncpy(s1, s2, n) char *s1, *s2; int n; {
  6.   char *strncpy;
  7.   strncpy = s1;
  8.   while(n--) if(!(*s1++ = *s2++)) break;
  9.   while(n-- > 0) *s1++ = 0;
  10.   return strncpy;
  11.   }
  12.